<template>
  <div class="project1Detail">
    <cheader :pageIndex="project"></cheader>
    <div class="banner">
      <img src="@/common/img/bg.png" alt="" class="bg">
      <div class="color" :style="{backgroundImage: 'linear-gradient('+ bannerBg[project] + ','+ bannerBg[project] +', #fff)'}"></div>
      <div class="content">
        <div class="p1-title">
          <div class="tWrap">
            <div class="t">
              <!-- <img src="@/common/img/ball1.png" alt=""> -->
              <img :src="ball" alt="">
              <!-- <img :src="'../../common/img/common/ball'+ (parseInt(project)+1) +'.png'" alt=""> -->
              <h2>“{{titleArr[project][blc].title1}}”</h2>
              <i></i>
            </div>
          </div>
          <div class="bWrap">
            <div class="b">
              <h3>{{titleArr[project][blc].title2}}</h3>
              <i></i>
            </div>
          </div>
        </div>
        <!-- <span class="goProject" @click="goProject">返回专题页 ></span> -->
      </div>
    </div>
    <div class="richWrap" ref="count">
      <div v-if="artileObj.dcover && artileObj.ctype != 1">
        <viewer>
          <img :src="artileObj.dcover" alt="" class="dcover">
        </viewer>
      </div>
      <div class="videoWrap" v-if="artileObj.ctype == 1 && artileObj.url">
        <video :src="artileObj.url" controls="controls" object-fit:="" fill="" class="mv" preload :poster='artileObj.cover'></video>
      </div>
      <h1>{{artileObj.title}}</h1>
      <h2 v-if="artileObj.writer">作者：{{artileObj.writer}}</h2>
      <div class="rich" v-html="artileObj.description"></div>
    </div>
    <cfooter v-if="artileObj.title"></cfooter>
  </div>
</template>
<script>
import cheader from '@/components/cheader/cheader'
import cfooter from '@/components/cfooter/cfooter'
import api from '@/common/js/api'
export default {
  data () {
    return {
      pageIndex: 0,
      bg: require('@/common/img/bg.png'),
      ball: '',
      project: 0,
      blc: '',
      test: 'http://mjd.artplanet.cn/files/175226--1jpg/%E6%9C%AA%E6%A0%87%E9%A2%98-1.jpg',
      bannerBg: [
        '#59bed9',
        '#d2964f',
        '#57a9d5',
        '#2e9a9a'
      ],
      titleArr: [
        // 专题一
        [
          {
            title1: '以笔为旗, 书写大爱',
            title2: '书法作品大合集'
          },
          {
            title1: '丹青妙手，聚暖生春',
            title2: '平面绘画作品大合集'
          },
          {
            title1: '字字珠玑，心灯长明',
            title2: '诗词作品'
          },
          {
            title1: '匠心独具，心系疫情',
            title2: '原创MV作品大合集'
          }
        ],
        // 专题二
        [
          {
            title1: '桃李不言，大爱交大',
            title2: ''
          },
          {
            title1: '战疫一线，唱响基层',
            title2: ''
          },
          {
            title1: '青春战疫，百炼成钢',
            title2: ''
          }
        ],
        // 专题三
        [
          {
            title1: '康康战疫记',
            title2: ''
          },
          {
            title1: '科技战疫',
            title2: ''
          },
          {
            title1: '建言献策',
            title2: ''
          },
          {
            title1: '科普知识',
            title2: ''
          }
        ],
        // 专题四
        [
          {
            title1: '躬先表率',
            title2: '优秀共产党员'
          },
          {
            title1: '医者仁心',
            title2: '照片集锦'
          },
          {
            title1: '心得感悟',
            title2: '手稿集锦'
          },
          {
            title1: '感动你我',
            title2: '专题短片'
          }
        ]
      ],
      did: '',
      postType: 0,
      artileObj: {},
      relateArr: []
    }
  },
  created () {
    this.project = this.$route.query.project
    this.blc = this.$route.query.blc
    this.did = this.$route.query.did
    api.articleDetail(this.did).then(res => {
      if (res.data.result === '0') {
        this.artileObj = res.data.data.detail
        this.relateArr = res.data.data.relate
      }
    })
  },
  mounted () {
    this.ball = require('../../common/img/ball' + (parseInt(this.project) + 1) + '.png')
  },
  updated () {
    let wH = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
    this.$refs.count.style.minHeight = wH - 252 + 'px'
  },
  methods: {
    goProject () {
      this.$router.push({
        name: 'project' + (parseInt(this.project) + 1)
      })
    },
    // 去文章详情页 (专题几，第几个模块, 后端参数id, 后端参数id)
    goToDetail (project, blc, did) {
      this.$router.push({
        name: 'projectDetail',
        query: {
          project: project,
          blc: blc,
          did: did
        }
      })
    },
    jump (e) {
      let did = e.target.dataset.did
      this.did = did
      this.goToDetail(this.project, this.blc, this.did)
    }
  },
  watch: {
    '$route' (to, from) {
      this.$router.go(0)
    }
  },
  components: {
    cheader,
    cfooter
  }
}
</script>
<style lang="scss" scoped>
  .project1Detail {
    .banner {
      height: 250px;
      background: center center no-repeat;
      // background-color: #000;
      width: 100%;
      overflow: hidden;
      position: relative;
      z-index: 1;
      .bg {
        display: block;
        width: 375px;
        height: 229px;
        position: absolute;
        top: 0;
        left: 50%;
        z-index: 2;
        margin-left: -187px;
      }
      .color {
        width: 100%;
        height: 250px;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 1;
        // opacity: .5;
      }
      .content {
        // background: #ccc;
        width: 100%;
        height: 100%;
        margin: 0 auto;
        position: relative;
        z-index: 3;
        text-align: center;
        padding-top: 100px;
        .p1-title {
          // position: absolute;
          // left: 0px;
          // bottom: 40px;
          .t {
            height: 30px;
            position: relative;
            display: inline-block;
            img {
              position: absolute;
              left: 0;
              top: 0;
              width: 29px;
              height: 29px;
            }
            h2 {
              font-size: 17px;
              color: #fff;
              position: relative;
              top: 11px;
              margin-left: 3px;
              font-weight: bold;
            }
            i {
              width: 5px;
              height: 5px;
              position: absolute;
              right: -3px;
              bottom: 0px;
              background-color: #ffe75f;
            }
          }
          .b {
            margin-top: 10px;
            display: flex;
            justify-content: space-between;
            position: relative;
            h3 {
              font-size: 14px;
              color: #fff;
              position: relative;
              z-index: 3;
              width: 100%;
            }
            i {
              color: #fff;
              font-size: 20px;
              font-style: normal;
              cursor: pointer;
            }
          }
        }
        .goProject {
          cursor: pointer;
          height: 20px;
          line-height: 20px;
          // background-color: red;
          color: #fff;
          position: absolute;
          bottom: 49px;
          right: 12px;
        }
      }
    }
    .richWrap {
      margin: -78px auto 10px;
      position: relative;
      z-index: 2;
      .dcover {
        display: block;
        max-width: 85%;
        // max-height: 350px;
        margin: 0 auto 14px;
        border-radius: 10px;
      }
      h1 {
        color: #494949;
        font-weight: bold;
        font-size: 17px;
        line-height: 24px;
        width: 90%;
        margin: 0 auto 14px;
      }
      h2 {
        width: 90%;
        margin: 0 auto 14px;
        font-size: 14px;
        line-height: 20px;
        font-weight: bold;
      }
      .videoWrap {
        margin-bottom: 15px;
        .mv {
          display: block;
          margin: 0 auto;
          max-width: 90%;
          max-height: 300px;
          border-radius: 10px;
        }
      }
      .rich {
        width: 90%;
        margin: 0 auto;
        font-size: 14px;
        line-height: 18px;
      }
      .rich >>> img {
        height: auto;
        max-width: 100%;
      }
    }
  }

</style>
